package com.dgut.controller;

import com.dgut.service.IAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/account")
public class AccountController {

    @Autowired
    private IAccountService accountService;

    //ModelAndView->setViewName设置转向地址（跳转的页面）
    @RequestMapping("/transForm")
    public ModelAndView gotroTrans(){
        ModelAndView mv = new ModelAndView();
        mv.setViewName("account/transForm");
        return mv;
    }

    public ModelAndView gotroTrans(int age){
        return null;
    }

    @RequestMapping("/trans")
    public ModelAndView trans(@RequestParam String from, @RequestParam String to, @RequestParam(required = true) Float money){

        accountService.trans(from,to,money);
        ModelAndView mv = new ModelAndView();
        mv.setViewName("account/trans");
//        Log log = new Log();
//        log.setContent("执行了【AccountController】中的-trans方法");
//        log.setVisitTime(new Date());
//        log.setIp(request.getLocalAddr());
//        logService.insert(log);
        return mv;
    }

}
